package com.github.shiqiyue.learn.guava;

import com.google.common.primitives.Chars;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

/***
 * 描述
 * @author wenyao.wu
 * @date 2018/7/3
 */
public class CharsTest {

    private static final Logger logger = LoggerFactory.getLogger(CharsTest.class);

    public static void main(String[] args) {
        char[] charArray = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'};

        //convert array of primitives to array of objects
        List<Character> objectArray = Chars.asList(charArray);
        logger.info("{}", objectArray);

        //convert array of objects to array of primitives
        charArray = Chars.toArray(objectArray);

        logger.info("{}", objectArray);
        //check if element is present in the list of primitives or not
        logger.info("c is in list? {}", Chars.contains(charArray, 'c'));

        //return the index of element
        logger.info("c position in list {}", Chars.indexOf(charArray, 'c'));

        //Returns the minimum
        logger.info("Min: {}", Chars.min(charArray));

        //Returns the maximum
        logger.info("Max: {}", Chars.max(charArray));
    }
}
